﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddProject.aspx.cs" Inherits="WebApplication2.Web.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../css/font.css" rel="stylesheet" />
    <link href="../css/xadmin.css" rel="stylesheet" />
    <script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../lib/layui/layui.js"></script>
    <script src="../js/xadmin.js"></script>
    <script src="../js/xcity.js"></script>
    <script src="../js/public.js"></script>
</head>
<body>
    <div class="x-body">
        <form class="layui-form">

            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>项目名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="PName" name="username" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                </div>
            </div>

              <%--//负责人--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>预算编号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="Pro_Id" name="Pro_Id" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                </div>
            </div>

                <%--//负责人--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>项目编号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="NewID" name="NewID" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                </div>
            </div>



            <%--//负责人--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>负责人
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="ChargerMan" name="chargeMan" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                </div>
            </div>

              <%--//使用区域--%>
            <div class="layui-form-item">
                <label class="layui-form-label">使用区域<span style="color: red"></span></label>
                <div class="layui-input-block" style="width: 190px">
                    <input type="text" name="" id="in_userArea" class="layui-input" style="position: absolute; z-index: 2;" lay-verify="required">
                </div>
            </div>

            <%--//项目引入时间--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>项目引入时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="inputTime" required=""
                        autocomplete="off" class="layui-input">
                </div>
            </div>
            <script>
                layui.use('laydate', function () {
                    var laydate = layui.laydate;

                    //执行一个laydate实例
                    laydate.render({
                        elem: '#inputTime' //指定元素
                    });
                });
            </script>

            <%--//项目预计交付时间--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>预计交付时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="finishTime" required=""
                        autocomplete="off" class="layui-input">
                </div>
            </div>
            <script>
                layui.use('laydate', function () {
                    var laydate = layui.laydate;

                    //执行一个laydate实例
                    laydate.render({
                        elem: '#finishTime' //指定元素
                    });
                });

            </script>

              <%--//项目性质--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>项目性质
                </label>
                <div class="layui-input-inline">
                    <select id="ProType" name="shipping" class="valid">
                        <option value="0">技改产能类</option>
                        <option value="1">新开发类</option>
                        <option value="2">现场支持无产生实际费用类</option>            
                    </select>
                </div>
            </div>

              <%--//资本化和费用化--%>
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red"></span>使用区域
                </label>
                <div class="layui-input-inline">
                    <select id="Caps" name="shipping" class="valid">
                        <option value="0">费用化</option>
                        <option value="1">资本化</option>
                        <option value="2">资本化与费用化</option>
                    
                    </select>
                </div>
            </div>

            <%--//项目预算--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>项目总预算
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="budge" required="" lay-verify="number"
                        autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span>元</span>
                </div>
            </div>

            <%--//项目产值--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>项目产值
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="value" required="" lay-verify="number" lay-verify="number"
                        autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span>元</span>
                </div>
            </div>

            <%--//电气装配--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>电气装配负责人
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="e_charge" name="phone"
                        autocomplete="off" class="layui-input">
                </div>
            </div>

            <%--//机械装配--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>机械装配负责人
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="m_charge" name="phone" required=""
                        autocomplete="off" class="layui-input">
                </div>
            </div>
            <%--//电气设计--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>电气设计
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="e_design" name="phone" required=""
                        autocomplete="off" class="layui-input">
                </div>
            </div>


            <%--//机械设计--%>
            <div class="layui-form-item">
                <label for="phone" class="layui-form-label">
                    <span class="x-red"></span>机械设计
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="m_design" name="phone" required=""
                        autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  增加
              </button>
          </div>
        </form>
       
    </div>
    <script>
                layui.use(['form', 'layer'], function () {
                    $ = layui.jquery;
                    var form = layui.form
                        , layer = layui.layer;

                    //监听提交
                    form.on('submit(add)', function (data) {
                        layer.confirm('你确定保存新项目吗', {
                            btn: ['确定', '放弃'] //按钮
                            
                        }, function () {
                            //Ajax上传逻辑
                            //第一个匿名函数是第一个按钮的回调function
                            sumitNew();
                          
                            //第二个匿名函数是第二个按钮的回调
                        }, function () {
                            //取消操作，弹出取消，不清除form表单里的信息

                        });
                       
                        return false;
                    });


                });


            /**
            记录操作者
            连同记录操作者记录一起AJax提交，在后端程序进行处理
          */
            function record() {
                var man;
                var project;
                var oprateType;
                var creatTime;
                var oprate;
                Console("");
            }

            function sumitNew() {
                var obj_project = {};
                obj_project.name = ($("#PName").val());
                console.log(obj_project.name);
                obj_project.chargeMan = ($("#ChargerMan").val());
                console.log(obj_project.chargeMan);
                //下拉框为空，取输入框的值
                obj_project.area = ($("#in_userArea").val());
                console.log(obj_project.area);
                obj_project.inputTime = ($("#inputTime").val());
                console.log(obj_project.inputTime);
                obj_project.finishTime = ($("#finishTime").val());
                console.log(obj_project.finishTime);
                obj_project.budget = ($("#budge").val());
                console.log(obj_project.budget);
                obj_project.value = ($("#value").val());
                console.log(obj_project.value);
                obj_project.m_design = ($("#m_design").val());
                console.log(obj_project.m_design);
                obj_project.m_charge = ($("#m_charge").val());
                console.log(obj_project.m_charge);
                obj_project.e_design = ($("#e_design").val());
                console.log(obj_project.e_design);
                obj_project.e_charge = ($("#e_charge").val());
                console.log(obj_project.m_charge);
                obj_project.caps = $("#Caps").val();
                console.log(obj_project.caps);
                obj_project.protype = $("#ProType").val();
                console.log(obj_project.protype);
                obj_project.pro_id = $("#Pro_Id").val();
                console.log(obj_project.protype);
                obj_project.NewID = $("#NewID").val();
               

                myAjax("projectHandler.ashx", "addProject", obj_project, false, function (data) {
                    //提示层
                    if (data.Code == 1) {
                        layer.msg('添加成功');
                        console.log(data);
                    }
                    else if (data.Code == 2)
                    {
                        layer.alert('已有一个 ' + $("#PName").val() + '', {
                            skin: 'layui-layer-molv' //样式类名
                            , closeBtn: 0
                            //动画类型
                        });

                    }
                   
                }, function () {
                    layer.alert('发生了一些预期之外的错误');
                    console.alert('发生一些意外');
                });
            }
    </script>

</body>
</html>
